name_list = ['里斯','张三','王五','王小二','张三']
num_list = [6,8,4,1,10]

#升序
name_list.sort()
num_list.sort()
print(num_list)

#降序
num_list.sort(reverse=True)

#逆序
num_list.reverse()

for my_name in name_list:
    print('我的名字是%s'%my_name)

#列表生成式
a =  [x for x in range(10)]

b = []
for x in range(10):
    b.append(x)

print(b)

x = [j for i in range(10) for j in range(i)]

a = [[col*row for col in range(5)] for row in range(5)]

#2维列表转一位列表
a = [j for x in a for j in x]  #相当于一个嵌套

#只筛选欧式
a = [x for x in range(10) if x % 2 == 0]

e = [x if x % 2 == 0 else x**2 for x in range(10)]

#列表简写操作
a = [1,2,3,4,5]
b = [1,2,3]
print(id(a))
print(id(a*2))
c = a*2
print(id(c))

c = [0] * 50  #快速初始化
print(c)

print(a+b)

a = a + b   #a的id发生改变
a+=b   ##等价于extend，a的id不发生改变









